package com.tanhua.model.vo;


import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Comment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageListVo {

    private String id;
    private String avatar;
    private String nickname;
    private String createDate;

    public static MessageListVo init(UserInfo userInfo, Comment comment){
        MessageListVo messageListVo = new MessageListVo();
        //设置id
        messageListVo.setId(userInfo.getId().toString());
        //设置头像
        messageListVo.setAvatar(userInfo.getAvatar());
        //设置昵称
        messageListVo.setNickname(userInfo.getNickname());
        //设置喜欢时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" yyyy-MM-dd hh:mm");
        String likeTime = simpleDateFormat.format(new Date(comment.getCreated()));
        messageListVo.setCreateDate(likeTime);
        return messageListVo;
    }
}
